package com.swiftride.controller.app;

import com.swiftride.param.PointParam;
import com.swiftride.result.R;
import com.swiftride.service.IDriverPointService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@Tag(name = "司机位置表", description = "司机位置表")
@RestController
@RequestMapping("/app/point")
public class DriverPointController {

    @Autowired
    public IDriverPointService driverPointService;

    //----------业务实现方法----------
    @Operation(summary = "保存位置", description = "保存位置接口")
    @Parameter(name = "pointParam", description = "订单参数对象", required = true)
    @PostMapping("/save")
    public R save(@RequestBody @NotNull PointParam pointParam) {
        driverPointService.save(pointParam);
        return R.success();
    }

    @Operation(summary = "根据订单编号获取位置", description = "根据订单编号获取位置接口")
    @Parameter(name = "orderNo", description = "订单编号", required = true)
    @PostMapping("/{orderNo}")
    public R<List<PointParam>> selectByOrderNo(@PathVariable(value = "orderNo") String orderNo) {
        return R.success(driverPointService.selectByOrderNo(orderNo));
    }

}
